﻿@{
    ViewBag.Title = "日志管理_按模块（菜单）查询";
}
<script type="text/javascript">

    var LastSelectID = 0; //最后一次选中的行ID
    var List_Permission_Log_QueryDateHeight = 0;
    $(document).ready(function () {
        List_Permission_Log_QueryDateHeight = $("#tabContent").innerHeight() - $(".panelBar").height();
        GridGet_QueryDate();
    });

    function GridGet_QueryDate() {
        $("#List_Permission_Log_QueryDate").jqGrid({
            url: "/Permission/Log/QueryByDate",
            datatype: "json",
            mtype: "post",
            colModel: [
                        { label: 'Id', name: 'LogId', width: 10, align: "center", sortable: false, hidden: true },
                        { label: '模块', name: 'ProcessName', width: 150, align: "center", sortable: false },
                        { label: '姓名', name: 'UserRealName', width: 60, align: "center", sortable: false },
                        { label: '访问时间', name: 'CreateOn', formatter: 'date', formatoptions: { srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d H:i:s' }, datefmt: 'Y-m-d H:i:s', width: 150, align: "center", sortable: false },
                        { label: 'IP地址', name: 'IPAddress', width: 150, align: "center", sortable: false },
                        { label: '操作', name: 'MethodName', width: 200, align: "center", sortable: false },
                        { label: '描述', name: 'Description', width: 100, align: "center", sortable: false }
                       ],
            beforeRequest: function (d) {
                $(this).jqGrid('setGridParam', { postData: { userId: $("#userId_QueryDate").val(), moduleId: $("#moduleId_QueryDate").val(), startDate: $("#txtStartDate_QueryDate").val(), endDate: $("#txtEndDate_QueryDate").val()} });
            },
            loadError: function (xhr, status) {
                alertMsg.error(xhr.responseText);
            },
            loadComplete: function (xhr) {
                var ajaxbg = $("#background,#progressBar,#lui_List_Permission_Log_QueryDate");
                ajaxbg.hide();
            },
            onSelectRow: Date_GetLogList,
            autowidth: true,
            shrinkToFit: true,
            multiselect: false,
            sortable: false,
            viewrecords: true,
            sortorder: "desc",
            jsonReader: {
                repeatitems: false
            },
            rowNum: 20,
            altRows: true,
            pager: '#pager_Permission_Log_QueryDate',
            rowList: [20, 50, 100],
            height: List_Permission_Log_QueryDateHeight - 130
        }).navGrid('#pager_Permission_Log_QueryDate', { edit: false, add: false, del: false, refresh: false, search: false });
    }
    //选中某一行，获得行
    function Date_GetLogList() {
        var GridObj_date = $("#List_Permission_Log_QueryDate");
        var logId_date = GridObj_date.jqGrid("getGridParam", "selrow");
        if (logId_date == "")
            return "";

        var temp_date = GridObj_date.getCell(parseInt(logId_date), "LogId").toString();
        return temp_date;
    }
    //对用户登录情况执行删除操作
    $("#del_Permission_Log_QueryDate").click(function () {
        var SelectLogIds_date = Date_GetLogList();
        if (SelectLogIds_date == "") {
            alertMsg.error("至少要勾选一条记录！");
            return false;
        }
        else {
            alertMsg.confirm("确定要删除吗？", {
                okCall: function () {
                    $.post("/Permission/Log/Delete", { "ids": SelectLogIds_date }, function (json) {
                        //1 接收参数 2 判断成功与否 3 根据返回的数据在树上新增节点
                        DWZ.ajaxDone(json);
                        if (json.statusCode == DWZ.statusCode.ok) {
                            //更新JqGrid
                            alertMsg.correct("成功删除！");
                            $("#List_Permission_Log_QueryDate").trigger("reloadGrid"); //重新加载JqGrid ;                            
                        }
                        else {
                            alertMsg.error("删除失败,请稍后再试！");
                        }
                    }, "json");
                }
            });
        }
    });
    //对用户登录情况执行全部删除操作
    //    $("#delAll_Permission_Log_QueryDate").click(function () {
    //        alertMsg.confirm("确定要全部清除吗？", {
    //            okCall: function () {
    //                $.post("/Permission/Log/Delete", { "ids": 0 }, function (json) {
    //                    //1 接收参数 2 判断成功与否 3 根据返回的数据在树上新增节点
    //                    DWZ.ajaxDone(json);
    //                    if (json.statusCode == DWZ.statusCode.ok) {
    //                        //清除所有JqGrid的数据行                           
    //                        $("#List_Permission_Log_QueryDate").clearGridData(true);
    //                        alertMsg.correct("全部清除完毕！");
    //                    }
    //                    else {
    //                        alertMsg.error("删除失败,请稍后再试！");
    //                    }
    //                }, "json");
    //            }
    //        });
    //    });
    //按条件查询日志
    $("#btnQuery_Permission_Log_QueryDate").click(function () {
        var jqgrid = $("#List_Permission_Log_QueryDate");
        jqgrid.trigger("reloadGrid"); //重新加载JqGrid 
    });
    $("#clearUser_QueryDate").click(function () {
        $("#userId_QueryDate").val("");
        $("#txtUserName_QueryDate").val("");
    });
    $("#clearModule_QueryDate").click(function () {
        $("#moduleId_QueryDate").val("");
        $("#txtModuleName_QueryDate").val("");
    });
</script>
<div class="pageHeader">
    <div class="searchBar">
        <table class="searchContent">
            <tr>
                <td class="td1">
                    开始结束日期：
                </td>
                <td>
                    <input type="text" id="txtStartDate_QueryDate" style="width:80px" value="@ViewBag.startDate" onclick="WdatePicker({maxDate:'#F{$dp.$D(\'txtEndDate_QueryDate\',{H:0});}',readOnly:true});" />
                    <input type="text" id="txtEndDate_QueryDate" style="width:80px" value="@ViewBag.endDate" onclick="WdatePicker({minDate:'#F{$dp.$D(\'txtStartDate_QueryDate\',{H:1});}',readOnly:true});" />
                </td>
                <td class="td1">
                    用户：
                </td>
                <td>
                    <input type="hidden" id="userId_QueryDate" value="" />
                    <input type="text" id="txtUserName_QueryDate" readonly="readonly" value="" />
                    <a class="btn btn-info btn-xs" href="/Permission/Log/SelectUser/2" target="dialog"
                        rel="dialog_permisson_log_QueryDate" title="切换用户" mask="true" width="550" height="450">
                        选择</a> <a class="btn btn-default btn-xs" href="javascript:void(0);" id="clearUser_QueryDate">
                            置空</a>
                </td>
                <td class="td1">
                    模块：
                </td>
                <td>
                    <input type="hidden" id="moduleId_QueryDate" value="" />
                    <input type="text" id="txtModuleName_QueryDate" readonly="readonly" value="" />
                    <a class="btn btn-info btn-xs" href="/Permission/Log/SelectModule/2" target="dialog"
                        rel="dialog_permisson_log_QueryDate" title="选择模块" mask="true" width="280" height="350">
                        选择</a> <a class="btn btn-default btn-xs" href="javascript:void(0);" id="clearModule_QueryDate">
                            置空</a>
                </td>
                <td>
                    <input type="button" class="btn btn-primary btn-xs" id="btnQuery_Permission_Log_QueryDate"
                        value="查询" />
                </td>
            </tr>
        </table>
    </div>
</div>
<div class="pageContent">
    <div id="mainContent_Permission_Log_QueryDate">
        <div class="tableList" layouth="40">
            <table id="List_Permission_Log_QueryDate">
            </table>
            <div id="pager_Permission_Log_QueryDate">
            </div>
        </div>
    </div>
</div>
